package com.hw.backapi.config;


import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

/**
 * @author lipeng
 * @description caffeine缓存配置
 * @date 2023/6/7 14:01
 */
@Configuration
public class CaffeineConfig {

    @Bean
    public Cache<String, Object> caffeineCacheObject(){
        return Caffeine.newBuilder()
                .initialCapacity(5)//最小容积
                .maximumSize(200)//最大值
                .expireAfterWrite(Duration.ofSeconds(60))//30s
                .build();
    }

}
